package com.hst.capacity.application.biz.impl;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor;
import com.hst.capacity.application.biz.MiniProgramBiz;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class MiniProgramBizImpl implements MiniProgramBiz {

    @Autowired
    private WxMaService wxMaService;

    public byte[] createDriverQrCode(String idDriver) {
        byte[] ret = null;
        try {
            WxMaCodeLineColor lineColor = new WxMaCodeLineColor();
            ret = wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(idDriver,
                    "" , false,"release",430,true,lineColor,true);
        } catch (WxErrorException e) {
            e.printStackTrace();
        }
        return ret;
    }

    public File createFileDriverQrCode(String idDriver) {
        File ret = null;
        try {
            WxMaCodeLineColor lineColor = new WxMaCodeLineColor();
            ret = wxMaService.getQrcodeService().createWxaCodeUnlimit(idDriver,
                    "" , false,"release",430,true,lineColor,true);
        } catch (WxErrorException e) {
            e.printStackTrace();
        }
        return ret;
    }

}
